<?php

namespace app\admin\model\workteam;

use think\Model;


class Files extends Model
{

    // 表名
    protected $name = 'workteam_files';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = '';
    //自定义日志标题
    protected static $title = '';
    //自定义日志内容
    protected static $content = '';

    protected static function init()
    {
        self::event('after_insert', function ($row) {
            $title = \app\admin\model\workteam\Log::getTitle();
            \app\admin\model\workteam\Log::record($row->project_id, 0, $title ? $title : __("添加附件"),['id'=>$row->id]);
        });
        self::event('after_delete', function ($row) {
            $title = \app\admin\model\workteam\Log::getTitle();
            \app\admin\model\workteam\Log::record($row->project_id, 0, $title ? $title : __("删除附件"),['id'=>$row->id]);
        });

    }

    /**
     * 创建者
     */
    public function admin()
    {
        return $this->belongsTo("\\app\\admin\\model\\Admin", 'admin_id');
    }

    /**
     * 关联任务
     */
    public function task()
    {
        return $this->belongsTo("\\app\\admin\\model\\workteam\\Task", 'task_id');
    }


    public function getStatusList()
    {
        return ['-1' => __('关闭'),'1' => __('进行中'), '0' => __('未开始'), '2' => __('完成'), '3' => __('归档')];
    }
}
